package net.zjitc.service;

import net.zjitc.dao.UserDao;
import net.zjitc.dao.UserDaoInmpl;
import net.zjitc.domain.User;

import java.sql.SQLException;

/**
 * Created by Administrator on 2017/10/8.
 */
public class UserServiceImpl implements UserService{
    public User findByUsernameAndPassword(String username, String password) {
        UserDao dao = new UserDaoInmpl();
        User user = dao.findByUsernameAndPassword(username,password);
        return user;
    }
    public int regist(User user) throws SQLException {
        UserDao userDao = new UserDaoInmpl();
        User existuser = userDao.findByUsername(user.getUsername());
        if (existuser == null){
            userDao.insert(user);
        }else{
            return 0;
        }
        return 1;
    }
}
